

package com.hazelcast.internal.serialization.impl.defaultserializers;

import com.hazelcast.internal.serialization.impl.SerializationConstants;
import com.hazelcast.nio.ObjectDataInput;

import java.io.IOException;
import java.util.concurrent.ArrayBlockingQueue;

/**
 * The {@link ArrayBlockingQueue} serializer
 * <p>
 * Important Note: The `fair` boolean is not be serialized since there is no public way to access it.
 */
public class ArrayBlockingQueueStreamSerializer<E> extends AbstractCollectionStreamSerializer<ArrayBlockingQueue<E>> {
    @Override
    public int getTypeId() {
        return SerializationConstants.JAVA_DEFAULT_TYPE_ARRAY_BLOCKING_QUEUE;
    }

    @Override
    public ArrayBlockingQueue<E> read(ObjectDataInput in) throws IOException {
        int size = in.readInt();

        ArrayBlockingQueue<E> collection = new ArrayBlockingQueue<>(size);

        return deserializeEntries(in, size, collection);
    }
}
